Home

Operator Usage

Name

spatch-map

Description

spatch-map[input-width, output-width, output-height, op] input-seq
spatch-map[input-width, skip-size, output-width, output-height, op] input-seq
convert an input sequence into a rectangular grid with the given input-width
then sub-divide that grid into "patches" of size output-width * output-height
then feed those patches to the passed in operator: op
the hope is that spatch-map[] will be useful for MNIST
if skip-size is defined, then skip patches
eg, if skip-size == 1, then don't skip any patches
if skip-size == 2, then skip every second patch
if skip-size == 3, then only process 1 in 3 patches, and so on


Examples

-- first, define a sequence:
the |seq> => ssplit[" "] |0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15>

-- now visualize this as a patch:
sdisplay-patch[4] the |seq>
    width:  4
    height: 4
    0  1  2  3
    4  5  6  7
    8  9  10 11
    12 13 14 15

-- now apply spatch-map[], and use sprint as the operator:
spatch-map[4, 2, 2, sprint] the |seq>
    |0> . |1> . |4> . |5>
    |1> . |2> . |5> . |6>
    |2> . |3> . |6> . |7>
    |4> . |5> . |8> . |9>
    |5> . |6> . |9> . |10>
    |6> . |7> . |10> . |11>
    |8> . |9> . |12> . |13>
    |9> . |10> . |13> . |14>
    |10> . |11> . |14> . |15>
    9|patches>

-- now the skip-size version, here, use skip-size == 2:
spatch-map[4, 2, 2, 2, sprint] the |seq>
    |0> . |1> . |4> . |5>
    |2> . |3> . |6> . |7>
    |8> . |9> . |12> . |13>
    |10> . |11> . |14> . |15>
    4|patches>


See also

Operator type

sequence compound context